import com.cn.Mapper.goodsMapper.CartMapper;
import com.cn.entity.goods.Goods_cart;
import com.cn.service.GoodsService.CartService;
import com.cn.util.SqlsesstionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @ClassName testCart
 * @Description TODO
 * @Author yujiajing
 * @Date 2022/10/11 20:28
 * @Version 1.0
 */
public class testCart {

    @Test
    public void InsertCart(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        Goods_cart goods_cart=new Goods_cart();
        cartMapper.InsertCart(goods_cart);
    }
    @Test
    public  void emptyCart(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        cartMapper.emptyCart();
    }
    @Test
    public  void updateCartByIdForNumber(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        cartMapper.updateCartByIdForNumber(30,"1");
    }
    @Test
    public  void ShowCart(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        List<Goods_cart>cartList =cartMapper.ShowCart();
        System.out.println(cartList.toString());
    }
    @Test
    public  void  addCartbyId(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartService cartService=new CartService();
        cartService.InsertCartByAuto("1");
    }
    @Test
    public void InsertCartByAuto(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        cartMapper.InsertCartById("1");
        cartMapper.updateCartByIdForNumber(1,"1");
    }
    @Test
    public  void deleteCartById(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        cartMapper.deleteCartById("1");
    }
   @Test
    public void autoAddOne(){

        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
      cartMapper.autoAddOne("1");

    }
    @Test
    public void analyseSubtotal(){

        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        CartMapper cartMapper=sqlSession.getMapper(CartMapper.class);
        cartMapper.analyseSubtotal("3");

    }

}
